package com.hospital.rank.module.controller;

import com.hospital.common.base.Result;
import com.hospital.common.dto.rank.module.RankSearchDto;
import com.hospital.common.vo.rank.module.PostRankVo;
import com.hospital.rank.module.base.PeriodType;
import com.hospital.rank.module.base.TargetType;
import com.hospital.rank.module.service.TRankService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 排行榜接口
 * @author yhn
 * @version 1.0
 */
@RestController
@RequestMapping("/rank")
public class RankController {
    @Autowired
    private TRankService rankService;

    /**
     * 排行榜查询
     */
    @PostMapping("/search")
    public Result<List<?>> rankSearch(@Valid @RequestBody RankSearchDto rankSearchDto) {
        return Result.success(rankService.rankSearch(TargetType.getTargetType(rankSearchDto.getTargetType()), PeriodType.getPeriodType(rankSearchDto.getPeriodType())));
    }
    /**
     * 热门贴查询
     */
    @GetMapping("/hotPostSearch")
    public Result<List<PostRankVo>> hostPostSearch() {
        return Result.success(rankService.hotPostSearch());
    }

    /**
     * 板块内排行查询
     */
    @PostMapping("/rankSearchInSection")
    public Result<List<?>> rankSearchInSection(@Valid @RequestBody RankSearchDto rankSearchDto){
        return Result.success(rankService.rankSearchInSection(rankSearchDto));
    }
}
